package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 * 缓冲字符流：java.io.BufferedWriter和Java。io。BufferedReader
 */
public class PwDemo {
    public static void main(String[] args) throws FileNotFoundException {
        /*
        PrintWriter pw = new PrintWriter("pw.text");
        pw.println("写信告诉我今天海是什么颜色 夜夜陪着你的海心情又如何");
        pw.println("灰色是不想说，蓝色是犹豫");
        System.out.println("写出完毕");
        pw.close();
        */

        //文件流：低级流/字节流
        FileOutputStream fos = new FileOutputStream("pw2.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw);
        pw.println("写信告诉我今天海是什么颜色 夜夜陪着你的海心情又如何");
        pw.println("灰色是不想说，蓝色是犹豫");
        System.out.println("写出完毕");
        pw.close();
    }
}